mod task;

use axum::{Router, extract::State, routing::get};
use ru::resp::{JsonRes, Resp};
use task::task_router;

use crate::state::AppState;

pub fn api_router() -> Router<AppState> {
    Router::new()
        .route("/health", get(handle_health))
        .merge(task_router())
}

async fn handle_health(State(state): State<AppState>) -> JsonRes<String> {
    state.db.ping().await?;

    Ok(Resp::msg("health good"))
}
